package config

const (
	ModelDBName     = "model"
	RpcServerDBName = "rpc_server"
)

type DBConfig struct {
	Clients []Client `json:"clients"`
}

type Client struct {
	Name string   `json:"name"`
	DNS  []string `json:"dns"`
}

func (dbConfig *DBConfig) ModelDBDNS() []string {
	return getDNSByName(ModelDBName, dbConfig.Clients)
}
func (dbConfig *DBConfig) RpcServerDNS() []string {
	return getDNSByName(RpcServerDBName, dbConfig.Clients)
}
func getDNSByName(clientName string, clients []Client) []string {
	var dns []string
	for _, client := range clients {
		if client.Name == clientName {
			dns = client.DNS
			break
		}
	}
	return dns
}
